import axios from '@/axios'
import JsonP from 'jsonp'

export function getHitokoto() {
  return axios({
    method: 'get',
    url: 'https://v1.hitokoto.cn/?c=i&encode=json',
  })
}
export function getSuggest(wd) {
  return new Promise((resolve, reject) => {
    JsonP('https://www.baidu.com/sugrec?prod=pc&wd=' + wd, { param: 'callback' }, (error, response) => {
      if (response.g) {
        resolve(response.g)
      }
    })
  })
}

export function getPhotos() {
  return axios({
    method: 'get',
    url: 'https://api.unsplash.com/photos/?client_id=EbTmbwtoi0nM8bTuKtW69CJB1hY6PNqADuH8pUeIivo',
  })
}

export function getRandomPhoto() {
  return axios({
    method: 'get',
    url: 'https://api.unsplash.com/photos/random?client_id=EbTmbwtoi0nM8bTuKtW69CJB1hY6PNqADuH8pUeIivo',
  })
}

export function getBingRandomPhoto() {
  return axios({
    method: 'get',
    url: 'https://api.xsot.cn/bing',
  })
}
